package com.example.academic_affairs_system.model.dto.user;

import com.example.academic_affairs_system.model.entity.AasUser;
import com.example.academic_affairs_system.utils.PasswordSecurity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;

import javax.validation.constraints.NotBlank;

/**
 * 注册 dto
 *
 * @author hjx
 * @since 2023/02/01 6:42 PM
 */
@Data
@Builder
@ApiModel("注册所需要的信息")
public class RegisterDTO {
  @ApiModelProperty("用户名")
  @NotBlank(message = "用户名不能为空")
  String username;

  @ApiModelProperty("密码")
  @NotBlank(message = "密码不能为空")
  String password;

  @ApiModelProperty("联系方式")
  @NotBlank(message = "联系方式不能为空")
  String concat;

  @ApiModelProperty("验证码")
  @NotBlank(message = "验证码不能为空")
  String verifyCode;

  public AasUser buildRegister() {
    AasUser aasUser = new AasUser();
    aasUser.setUsername(username);
    aasUser.setPassword(PasswordSecurity.generatedPassword(password));
    aasUser.setConcat(concat);
    return aasUser;
  }
}
